home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk125 / usmap / readme < prev    next >
Text File  |  1995-03-19  |  5KB  |  104 lines

  1.  
  2. Here is an example of one way to implement irregularly shaped buttons 
  3. in The Director.  The example used is a US map, where each state is a 
  4. seperate button.
  5.  
  6. This demo for this example, and the utility that helps to create a
  7. table of buttons for applications like the example, can both be run
  8. using the Projector, The Director's player program which can be found 
  9. elsewhere in this library.
  10.  
  11. The technique used is this.  First, the screen image is designed in
  12. a paint program or whatever, where there are areas on the screen that
  13. are to be used as buttons.  Then a second version of this screen image
  14. is created, and all of the active button areas replaced with solid
  15. colors.  Compare the IFF image files, USMAP1 and USMAP2 to see an 
  16. example.  USMAP2 has each button area colored in as a solid color.  
  17. It is also important to use colors so that a rectangle can be drawn around 
  18. any button that will not overlap another button of the same color.  
  19. In the example USMAP2, only 6 colors are used to color the states.
  20.  
  21. It is determined that a given button has been clicked, when two conditions
  22. are met:  1. The click occurs within the buttons boundary rectangle, and
  23. 2. The pixel color of the clicked-on pixel in the mask image (USMAP2) 
  24. is the proper color.
  25.  
  26. A table in the array is used to hold all of the button locations and 
  27. colors.  Every 7 elements constitute a button entry, where the upper 
  28. left x,y, lower right x,y, color values and fill location (for highlighting)
  29. are contained.  The table ends with a -1 as the upper left x value.  
  30. Example:
  31.  
  32.     50        upper left x
  33.     50        upper left y
  34.     100        lower right x
  35.     75        lower right y
  36.     7        color 7 for this button
  37.     70        fill location x
  38.     70        fill location y
  39.     -1        end of table
  40.  
  41. To facilitate easy creation of the button table, a Director utility script,
  42. "gbuttons" was created that will allow you the mask image to be loaded and
  43. the boundary rectangle specified (by clicking once in each corner of the
  44. rectangle, and then hitting return) and then the proper color of the 
  45. button selected by clicking on the button itself.  "gbuttons" will create
  46. a file, "ram:btable" which contains all of the data for the buttons 
  47. specified.  This file can then be used as in the example "domap" script
  48. (where ram:btable has been renamed "us.table") read in to the array
  49. and used to define the button areas in the application.  Note that
  50. every time "gbuttons" is rerun the file "ram:btable" will be created
  51. as new, deleting any old data that may be in the file from the previous
  52. use of "gbuttons".  It is a good idea to rename the "ram:btable" file
  53. once it has been created.  Since the file produced is readable ASCII,
  54. it is possible to cut and paste these files to assemble button data
  55. generated independently, but remember that each button consists of 7
  56. values, and there is a -1 only at the end of the table.
  57.  
  58.  
  59. The script "domap" loads in the button screen and the button mask,
  60. and starts in a demo mode where the states are highlighted at random.
  61.  
  62. Once the mouse is clicked on a state, a window will appear with the
  63. text that is contained in a text file associated with the button.  These
  64. text files are named STATE01...STATE48  (Alaska & Hawaii weren't 
  65. included).  When the mouse is clicked, it's location is converted into 
  66. a button number from 1-48, or a 0 if no button was hit.  (actually, 1-50,
  67. as buttons 49 and 50 are the exit and demo buttons).  The button number
  68. is converted into the appropriate state's filename, and the file is
  69. read and displayed in the text window.
  70.  
  71. Highlighting is accomplished by coping the mask image into a scratch
  72. buffer and FILLing from the fill point in the button table with color 0.
  73. This resultant image is then used to stencil a solid color screen image 
  74. into place on the viewed map.  This stencil technique requires the use 
  75. of up to 4 buffers which may make it impractical for hi-res applications, 
  76. though there may be other highlighting techniques that could be 
  77. substituted, or highlighting could be dispensed with entirely.  If a 
  78. hi-res version is desired, you might note that the mask image does not 
  79. have to be hi-res, the x,y mouse coordinates could be halved and used 
  80. with a low-res mask image, since the mask image is never seen anyway.
  81.  
  82. To run the examples from the workbench, download a copy of The Director's
  83. "projector" program from this library, and type:
  84.  
  85.     projector domap.film
  86.  
  87. to run the finished application example, or:
  88.  
  89.     projector gbuttons.film
  90.  
  91. to run the button utility.  Specify USMAP2 as the mask image when
  92. using the US map to try the button utility.
  93.  
  94. To run these examples from the Workbench, copy the projector and
  95. the projector's icon file "projector.info" into the directory that
  96. contains the files for the demos, and click on the icons from the
  97. Workbench.
  98.  
  99. Good luck.
  100.  
  101. Keith Doyle
  102. 4/10/90
  103.  
  104.